package com.jfinal_demo.app.controllers;

import com.jfinal.aop.Before;
import com.jfinal.ext.interceptor.GET;
import com.jfinal.ext.interceptor.POST;
import com.jfinal_demo.app.services.TagService;

public class TagController extends BaseController {
    private final TagService tagService = enhance(TagService.class);

    @Before(GET.class)
    public void list() {
        renderJson(tagService.list());
    }

    @Before(POST.class)
    public void createTag() {
        String tagName = getPara("tagName");
        renderJson(tagService.createTag(tagName));
    }

    public void deleteTag() {
        long tagId = getParaToLong("tagId");
        renderJson(tagService.deleteTag(tagId));
    }
}
